﻿<?php
session_start();
include "connectsql.php";

$showtxt = "machineonlinestart:";
if (isset($_SESSION["ceo"]) && $_SESSION["ceo"] == true) {
	date_default_timezone_set('PRC');
	$now = time() - 60;
	$manager = $_SESSION["manager"];
	
	$error = "";
	$sql = "select * from ".SetDB_USER_TAB($manager)." where `online_time` >= '".$now."'";
	if ($query = mysqli_query($link, $sql)) {
		$num = 0;
		while ($row = mysqli_fetch_assoc($query)) {
			$username = $row["username"];
			$gprs = $row["extrainfo"];
			$modexml = $row["modexml"];
			$playlistxml = $row["playlistxml"];
			$ip = $row["userip"];
			$loginmode = $row["loginmode"];
			$login_time = $row["login_time"];
			$ver = $row["ver"];
			$downloadfile = $row["downloadfile"];
			$downloadper = $row["downloadper"];
			$playfile = $row["playfile"];
			$mcu = $row["mcu"];
			$wifi = $row["wifi"];
			$downloadspeed = $row["downloadspeed"];
			$network = $row["network"];
			$gps = $row["gps"];
			$error = $row["error"];
			
			if ($login_time == 0) {
				$login_time = "";
			}	else {
				$login_time = date('Y-m-d H:i:s', $login_time);			
			}
			if ($num != 0) {
				$showtxt .= ";;";
			}
			$showtxt .= $username.",,".$ip.",,".$loginmode.",,".$login_time.",,".$modexml.",,".$playlistxml.",,".$ver.",,".$downloadfile.",,".$downloadper.",,".$playfile.",,".$gprs.",,".$mcu.",,".$wifi.",,".$downloadspeed.",,".$network.",,".$gps.",,".$error;
			$num++;
		}
		mysqli_free_result($query);
	}
}
$showtxt .= ":machineonlineover";
echo $showtxt;
mysqli_close($link);
?>